﻿package newcommerce.lastfm.api
{
	import newcommerce.lastfm.api.data.LFMAlbumData;
	import newcommerce.lastfm.api.data.LFMArtistInfo;
	import newcommerce.lastfm.api.data.LFMBioData;
	import newcommerce.lastfm.api.data.LFMEventData;
	import newcommerce.lastfm.api.data.LFMImageData;
	import newcommerce.lastfm.api.data.LFMLocationData;
	import newcommerce.lastfm.api.data.LFMSimilarArtistData;
	import newcommerce.lastfm.api.data.LFMVenueData;	
	import newcommerce.lastfm.api.feeds.LFMAlbumFeed;
	import newcommerce.lastfm.api.feeds.LFMEventFeed;
	import newcommerce.lastfm.api.feeds.LFMImageFeed;
	import newcommerce.lastfm.api.feeds.LFMSimilarArtistFeed;
	
	/**
	 * ...
	 * @author Martin Legris ( http://blog.martinlegris.com )
	 */
	public class LastFMTracer 
	{
		public static function traceSimilarArtists(feed:LFMSimilarArtistFeed):void
		{
			trace("\nthere are " + feed.count + " artists similar to " + feed.artist);
			
			var artist:LFMSimilarArtistData;
			while (artist = feed.next())
			{
				traceSimilarArtist(artist);
			}
		}
		
		public static function traceSimilarArtist(artist:LFMSimilarArtistData):void
		{
			trace("\nartist.name: " + artist.name);
			trace("artist.match: " + artist.match);
			trace("artist.mbid: " + artist.mbid);
			trace("artist.url: " + artist.url);
			trace("artist.streamable: " + artist.streamable);
			traceImages(artist.images);
		}
		
		public static function traceImages(images:LFMImageFeed):void
		{
			trace("[" + images.count + " images found ]");
			var image:LFMImageData;
			while (image = images.next())
			{
				traceImage(image);
			}
		}
		
		public static function traceImage(image:LFMImageData):void
		{
			trace("[" + image.size + "] " + image.url);
		}
		
		public static function traceArtistInfo(ai:LFMArtistInfo):void
		{
			trace("ai.name: " + ai.name);
			trace("ai.mbid: " + ai.mbid);
			trace("ai.url: " + ai.url);
			trace("ai.playCount: " + ai.playCount);
			trace("ai.listeners: " + ai.listeners);
			trace("ai.streamable: " + ai.streamable);
			traceBioData(ai.bio);
			traceImages(ai.images);
			traceSimilarArtists(ai.similar);
		}
		
		public static function traceBioData(bio:LFMBioData):void
		{
			trace("bio.summary: " + bio.summary);
			trace("bio.published: " + bio.published)
			trace("bio.content: " + bio.content);
		}
		
		public static function traceAlbums(feed:LFMAlbumFeed):void
		{
			trace("\n[" + feed.count + "] albums");
			var album:LFMAlbumData;
			while (album = feed.next())
				traceAlbum(album);
		}
		
		public static function traceAlbum(album:LFMAlbumData):void
		{
			trace("\nalbum.name: " + album.name);
			trace("album.mbid: " + album.mbid);
			trace("album.url: " + album.url);
			trace("album.playCount: " + album.playCount);
			traceImages(album.images);
		}
		
		public static function traceEvents(feed:LFMEventFeed):void
		{
			trace("\n[" + feed.count + "] events");
			var event:LFMEventData;
			while (event = feed.next())
				traceEvent(event);
		}
		
		public static function traceEvent(event:LFMEventData):void
		{
			trace("\nevent.artists: " + event.artists);
			trace("event.attendance: " + event.attendance);
			trace("event.description: " + event.description);
			trace("event.headliner: " + event.headliner);
			trace("event.id: " + event.id);
			trace("event.reviews: " + event.reviews);
			trace("event.startDate: " + event.startDate);
			trace("event.startTime: " + event.startTime);
			trace("event.tag: " + event.tag);
			trace("event.url: " + event.url);
			traceVenue(event.venue);
			traceImages(event.images);
		}
		
		public static function traceVenue(venue:LFMVenueData):void
		{
			trace("\nvenue.name: " + venue.name);
			traceLocation(venue.location);
		}
		
		public static function traceLocation(location:LFMLocationData):void
		{
			trace("\nlocation.street: " + location.street);
			trace("location.city: " + location.city);
			trace("location.country: " + location.country);
			trace("location.postalcode: " + location.postalcode);
			trace("[lat] " + location.lat + " [long] " + location.long);
			trace("location.timezone: " + location.timezone);
		}
	}
}